<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>{{.s_title}}</title>
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.min.css" rel="stylesheet" />
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/other/all.css" rel="stylesheet" />
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/other/app.css" rel="stylesheet" />
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/font/iconfont.css" rel="stylesheet" />
</head>
<style type="text/css">
	.shopping_cart ul { margin-bottom: 0; }
	.shopping_cart ul li .cart_top>span{
		background: url(../img/cart/checked1.png);
		 background-size: 100%;
	}
	.settlement p .catoption_header{
		background: url(../img/cart/checked1.png);
		 background-size: 100%;
	}
	.shopping_cart {
	    padding-bottom: 45px;
	}
	.mui-numbox{
		height: 30px;
		padding: 0 30px;
		width: 92px;
	}
	.mui-numbox .mui-input-numbox, .mui-numbox .mui-numbox-input{
		width: 30px!important;
		padding: 0 0px!important;
	}
	.mui-numbox [class*=btn-numbox], .mui-numbox [class*=numbox-btn]{
		width: 30px;
	}
	html,body{
		height: 100%;
	}
	footer { width: 100%; height: 45px; background-color: #fff; border-top: 1px solid #eee; position: fixed; bottom: 0; left: 0; }
	footer p { float: left; line-height: 45px; margin: 0 10px; color: #e54242;  font-size: 13pt;}
	footer p span { margin-right: 2px; font-size: 9pt; }
	footer button { float: right; width: 90px; height: 100%; border: none; background-color: #e54242; color: #fff; border-radius: 0; }
	.rcmdPrdList dl i.iconfont{position:absolute;bottom: 10px;right:5px;font-size: 18pt}
</style>
<body>
<div class="shopping_cart">
	<form>

	<div class="rcmdPrdList">
	{{range .product}}
	<dl class="goto">
		<dt  class="goto" href="/mobile/column/product_content?id={{.id}}">
			<img src="{{.pathname}}" alt="">
		</dt>
		<dd>
			<p>{{.title}}</p>
			<p>
			<span>&yen; <span class="bprice">{{.price}}</span></span>
			</p>
			<p>最小购买数量为{{.minbuy}}</p>
		</dd>
		<i class="iconfont scadd" data-id="{{.id}}">&#xe7a1;</i>
		<input class="mui-input-numbox numbox jg_val" type="hidden" value="1" name="num"/>
		<input type="hidden" name="id" value="{{.id}}">
		<input type="hidden" name="number" value="{{.number}}">
		<input type="hidden" name="minbuy" value="{{.minbuy}}">
	</dl>
	{{end}}
	</div>
	</form>
</div>
<footer>
	<p><span>合计：&yen;</span><b id="price">199.00</b></p>
	<button id="addcar">加入购物车</button>
</footer>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/other/app.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/js/SUI.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.min.js"></script>
<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/zepto.min.js"></script>
<script>
	$('.scadd').click(function(){
		var that=$(this)
		mui.confirm("你确定要移除该产品吗?",function(res){

			if(res.index==1){
				that.parent().remove()
			}
			pricechange()
		})
	})
	function pricechange(){
		var li=$('dl.goto')
		var price=0.00
		li.each(function(){
			var priceone=$(this).find('.bprice').html()
			var num=$(this).find('input[name="number"]').val()
			var minbuy=$(this).find('input[name="minbuy"]').val()
			var pricen= 0
			if (minbuy>1) {
				pricen = parseFloat(priceone)*parseFloat(num)*parseFloat(minbuy)
			} else {
				pricen = parseFloat(priceone)*parseFloat(num)
			}
			// console.log(priceone,num,pricen)
			price+=pricen
		})
		// console.log(price)
		price=price.toFixed(2)
		$('#price').html(price)
	}
	pricechange()
	$('#addcar').click(function(){
		var form=$('form').serialize()
		var form={};
		var ids=[];
		var nums=[];
		$('input[name="id"]').each(function(){
			ids.push($(this).val())
		})
		// $('input[name="num"]').each(function(){
		// 	nums.push($(this).val())
		// })
		$('input[name="minbuy"]').each(function(){
			nums.push($(this).val())
		})
		form.id=ids.join(",")
		form.num=nums.join(",")
		$.ajax({
			url:window.location.href,
			type:'post',
			data:form,
			success:function(res){
				if(res==1){
					mui.alert("添加成功",function(){
						window.location.href="/mobile/shopcar"
					})
				}else if(res==962){
					mui.confirm("您还没有登入,请先登入",function(e){
						if(e.index==1){
		             		 window.location.href="/mobile/login"
						}
		            })
				}else if(res==3){
		          mui.toast('库存不足');
				}else{
					mui.toast("网络繁忙,请稍后再试!")
		        }
			}
		})
	})




    mui.init({
        swipeBack:true //启用右滑关闭功能
    });
    //释放 nav 底部导航 a 链接
    mui('.mui-tab-item').each(function () {
        this.addEventListener('tap',function () {
            var url = this.getAttribute('href');
            window.location.href=url;
        })
    });
</script>
<div class="mt-statistics">统计代码</div>
</body>
</html>
<script></script>
